import numpy as np
def iid(dataset, args):
    idxs = np.arange(len(dataset))
    labels = np.transpose(np.array(dataset.targets))

    dict_users = {i: list() for i in range(args.num_clients)}

    np.random.shuffle(idxs)  # 对索引进行随机打乱

    num_samples_per_client = len(dataset) // args.num_clients  # 每个客户端的样本数量

    for i in range(args.num_clients):
        start_idx = i * num_samples_per_client
        end_idx = (i + 1) * num_samples_per_client
        dict_users[i] = set(idxs[start_idx:end_idx])  # 将样本索引划分给每个客户端

    return dict_users
